﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DOTNETGROUP.Entities;
using DOTNETGROUP.Data;

public partial class Controls_ControlKhoaHocLeft : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            HienThiChuyenMucThuNhat();
            HienThiChuyenMucThuHai();
            HienThiChuyenMucThuBa();
        }
    }

    private void HienThiChuyenMucThuNhat()
    {
        TList<KhoaHoc> TList_KhoaHoc = DataRepository.KhoaHocProvider.Find("Id=" + Request.Params["Id"]);
        if (TList_KhoaHoc.Count > 0)
        {
            int TotalRows = 0;
            string WhereClause = "1=1 and TrangThai=1 and IdLoaiKhoaHoc = " + TList_KhoaHoc[0].IdLoaiKhoaHoc;
            TList<KhoaHoc> TList_TinTuc = DataRepository.KhoaHocProvider.GetPaged(WhereClause, "NgayCapNhat DESC", 0, 10, out TotalRows);
            if (TList_TinTuc.Count <= 0) return;
            dlChuyenMuc1.DataSource = TList_TinTuc;
            dlChuyenMuc1.DataBind();
        }
    }

    private void HienThiChuyenMucThuHai()
    {

        int TotalRows = 0;
        string WhereClause = "1=1 and TrangThai=1";
        TList<KhoaHoc> TList_TinTuc = DataRepository.KhoaHocProvider.GetPaged(WhereClause, "NgayCapNhat DESC", 0, 10, out TotalRows);
        if (TList_TinTuc.Count <= 0) return;
        dlChuyenMuc2.DataSource = TList_TinTuc;
        dlChuyenMuc2.DataBind();
    }

    private void HienThiChuyenMucThuBa()
    {
        int TotalRows = 0;
        string WhereClause = "1=1 and TrangThai=1";
        TList<KhoaHoc> TList_TinTuc = DataRepository.KhoaHocProvider.GetPaged(WhereClause, "NEWID()", 0, 10, out TotalRows);
        if (TList_TinTuc.Count <= 0) return;
        dlChuyenMuc3.DataSource = TList_TinTuc;
        dlChuyenMuc3.DataBind();
    }

    public string GetTieuDe(object Char)
    {
        string s = Char.ToString();
        return Common.ConvertToUnSign(s);
    }
}